﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VicMessenger.DB;

namespace VicMessenger.DAL
{
    class CategoryDAL
    {
        public static List<proc_Category_SelectResult> GetCategory(int? prmCategoryID)
        {
            try
            {
                using (CategoryDataContext db = new CategoryDataContext())
                {
                    return db.proc_Category_Select(prmCategoryID).ToList();
                }
            }
            catch (Exception)
            {
                return null;
            }
        }

        public static int? InsertUpdateCategory(proc_Category_SelectResult prmCategory)
        {
            try
            {
                int? retID = 0;
                using (CategoryDataContext db = new CategoryDataContext())
                {
                    db.proc_Category_InsertUpdate(prmCategory.CategoryID,
                                                  prmCategory.CategoryName.Trim(),
                                                  prmCategory.Description.Trim(),
                                                  ref retID);




                    return retID;
                }
            }
            catch (Exception)
            {
                return 0;
            }
        }

        public static int DeleteCategory(int prmCategoryId)
        {
            try
            {
                using (CategoryDataContext db = new CategoryDataContext())
                {
                    return db.proc_Category_Delete(prmCategoryId);
                }
            }
            catch (Exception)
            {
                return 0;
            }
        }
    }
}
